import java.util.Arrays;

import org.apache.log4j.BasicConfigurator;

import edu.mit.csail.sdg.alloy4.Util;
import edu.mit.csail.sdg.alloy4compiler.ast.Attr;
import edu.mit.csail.sdg.alloy4compiler.ast.Expr;
import edu.mit.csail.sdg.alloy4compiler.ast.ExprQt;
import edu.mit.csail.sdg.alloy4compiler.ast.Sig.PrimSig;
import edu.mit.csail.sdg.alloy4compiler.parser.CompUtil;
import edu.mit.csail.sdg.alloy4whole.Helper;

import pl.edu.pw.elka.dzielins.revanalyzer.Project;
import pl.edu.pw.elka.dzielins.revanalyzer.alloy.AlloyException;
import pl.edu.pw.elka.dzielins.revanalyzer.alloy.io.Reader;
import pl.edu.pw.elka.dzielins.revanalyzer.alloy.io.Writer;
import pl.edu.pw.elka.dzielins.revanalyzer.instance.InstanceObject;
import pl.edu.pw.elka.dzielins.revanalyzer.instance.InstanceRelation;
import pl.edu.pw.elka.dzielins.revanalyzer.model.Model;
import pl.edu.pw.elka.dzielins.revanalyzer.model.ModelRelation;
import pl.edu.pw.elka.dzielins.revanalyzer.utils.CombinatoricsUtils;


public class test2 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		BasicConfigurator.configure();
		Reader reader = new Reader();
		Writer writer = new Writer();
		try {
			Project project = reader.readAlloy(null, "tests/model01a.als");
			//System.out.println(project.getModel().toString());
			InstanceObject set;
			set = new InstanceObject("Set01", project.getModel().getObject("model01b/Set"));
			project.getInstance().getObjects().add(set);
			for (int i = 0; i < 10; ++i) {
				InstanceObject element = new InstanceObject("Element" + i, project.getModel().getObject("model01b/Element"));
				project.getInstance().getObjects().add(element);
				ModelRelation relation = element.getPossibleRelation("elements");
				if (relation!=null)
					set.addRelation(new InstanceRelation("elements", relation, element));
			}
			writer.writeAlloy(project,"test01");
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}

}
